{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Finding 3-Digit Even Numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #hash-table #enumeration #sorting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #哈希表 #枚举 #排序"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: findEvenNumbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #找出 3 位偶数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个整数数组 <code>digits</code> ，其中每个元素是一个数字（<code>0 - 9</code>）。数组中可能存在重复元素。</p>\n",
    "\n",
    "<p>你需要找出 <strong>所有</strong> 满足下述条件且 <strong>互不相同</strong> 的整数：</p>\n",
    "\n",
    "<ul>\n",
    "\t<li>该整数由 <code>digits</code> 中的三个元素按 <strong>任意</strong> 顺序 <strong>依次连接</strong> 组成。</li>\n",
    "\t<li>该整数不含 <strong>前导零</strong></li>\n",
    "\t<li>该整数是一个 <strong>偶数</strong></li>\n",
    "</ul>\n",
    "\n",
    "<p>例如，给定的 <code>digits</code> 是 <code>[1, 2, 3]</code> ，整数 <code>132</code> 和 <code>312</code> 满足上面列出的全部条件。</p>\n",
    "\n",
    "<p>将找出的所有互不相同的整数按 <strong>递增顺序</strong> 排列，并以数组形式返回<em>。</em></p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>digits = [2,1,3,0]\n",
    "<strong>输出：</strong>[102,120,130,132,210,230,302,310,312,320]\n",
    "<strong>解释：</strong>\n",
    "所有满足题目条件的整数都在输出数组中列出。 \n",
    "注意，答案数组中不含有 <strong>奇数</strong> 或带 <strong>前导零</strong> 的整数。</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>digits = [2,2,8,8,2]\n",
    "<strong>输出：</strong>[222,228,282,288,822,828,882]\n",
    "<strong>解释：</strong>\n",
    "同样的数字（0 - 9）在构造整数时可以重复多次，重复次数最多与其在 <code>digits</code> 中出现的次数一样。 \n",
    "在这个例子中，数字 8 在构造 288、828 和 882 时都重复了两次。 \n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>digits = [3,7,5]\n",
    "<strong>输出：</strong>[]\n",
    "<strong>解释：</strong>\n",
    "使用给定的 digits 无法构造偶数。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>3 &lt;=&nbsp;digits.length &lt;= 100</code></li>\n",
    "\t<li><code>0 &lt;= digits[i] &lt;= 9</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [finding-3-digit-even-numbers](https://leetcode.cn/problems/finding-3-digit-even-numbers/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [finding-3-digit-even-numbers](https://leetcode.cn/problems/finding-3-digit-even-numbers/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[2,1,3,0]', '[2,2,8,8,2]', '[3,7,5]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        res = []   # 目标偶数数组\n",
    "        freq = Counter(digits)   # 整数数组中各数字的出现次数\n",
    "        # 枚举所有三位偶数，维护整数中各数位的出现次数并比较判断是否为目标偶数\n",
    "        for i in range(100, 1000, 2):\n",
    "            freq1 = Counter([int(d) for d in str(i)])\n",
    "            if all(freq[d] >= freq1[d] for d in freq1.keys()):\n",
    "                res.append(i)\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        def traverse(s):\n",
    "            if 99 < s < 1000:\n",
    "                if s % 2 == 0:\n",
    "                    res.append(s)\n",
    "                return \n",
    "            pre = -1\n",
    "            for i, x in enumerate(digits):\n",
    "                if used[i] or x == pre:\n",
    "                    continue\n",
    "                if s*10 + x:\n",
    "                    used[i] = 1\n",
    "                    traverse(s*10 + x)\n",
    "                    used[i] = 0\n",
    "                pre = x\n",
    "            \n",
    "        digits.sort()\n",
    "        res = []\n",
    "        used = [0] * len(digits)\n",
    "        traverse(0)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        g = collections.Counter(sorted(digits))\n",
    "        ans = []\n",
    "        def dfs(path):\n",
    "            if len(path) == 3:\n",
    "                res = path[0] * 100 + path[1] * 10 + path[2]\n",
    "                if res > 99 and res % 2 == 0:\n",
    "                    ans.append(res)\n",
    "                return\n",
    "            for i in g:\n",
    "                if g[i] > 0:\n",
    "                    g[i] -= 1\n",
    "                    path.append(i)\n",
    "                    dfs(path)\n",
    "                    g[i] += 1\n",
    "                    path.pop()\n",
    "        dfs([])\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        ans = set()\n",
    "        n = len(digits)\n",
    "        def dfs(cur, wei, used):\n",
    "            if wei==0:\n",
    "                for i in range(n):\n",
    "                    if digits[i]&1:\n",
    "                        continue\n",
    "                    used.append(i)\n",
    "                    dfs(digits[i], 1, used)\n",
    "                    used.pop()\n",
    "            elif wei==2:\n",
    "                for i in range(n):\n",
    "                    if i in used or digits[i]==0:\n",
    "                        continue\n",
    "                    ans.add(cur + 100*digits[i])\n",
    "            else:\n",
    "                for i in range(n):\n",
    "                    if i in used:\n",
    "                        continue\n",
    "                    used.append(i)\n",
    "                    dfs(cur + 10*digits[i], 2, used)\n",
    "                    used.pop()\n",
    "        \n",
    "        dfs(0, 0, [])\n",
    "        return sorted(list(ans))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from itertools import permutations\n",
    "from typing import List\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        digits = self.handle_digits(digits)\n",
    "        res_list = [\"\".join(str(x) for x in i)\n",
    "                    for i in list(permutations(digits, 3))]\n",
    "        res_list = list(set(res_list))\n",
    "        res = res_list.copy()\n",
    "        for item in res_list:\n",
    "            if item[0] == \"0\" or (int(item) & 1 != 0):\n",
    "                res.remove(item)\n",
    "        return sorted([int(x) for x in res])\n",
    "\n",
    "    @staticmethod\n",
    "    def handle_digits(digits):\n",
    "        d = Counter(digits)\n",
    "        for k, v in d.items():\n",
    "            if v <= 3:\n",
    "                continue\n",
    "            while v > 3:\n",
    "                digits.remove(k)\n",
    "                v -= 1\n",
    "\n",
    "        return digits\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        import copy\n",
    "        n = len(digits)\n",
    "        target = []\n",
    "        digits_odd = {num for num in digits if num % 2 == 0}\n",
    "        for num in digits_odd:\n",
    "            digits_num = copy.copy(digits)\n",
    "            digits_num.remove(num)\n",
    "            for i in range(n-2):\n",
    "                for j in range(i+1, n-1):\n",
    "                    str_v_1 = str(digits_num[i]) + str(digits_num[j]) + str(num)\n",
    "                    str_v_2 = str(digits_num[j]) + str(digits_num[i]) + str(num)\n",
    "                    target.extend([str_v_1, str_v_2])\n",
    "        target = [int(t) for t in list(set(target)) if len(str(int(t))) == 3]\n",
    "        target.sort()\n",
    "        return target\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from numpy import unique\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        n=len(digits)\n",
    "        dic=Counter(digits)        \n",
    "        if n<3: return []            \n",
    "        res=[]        \n",
    "        digits=[*dic]\n",
    "        for i in range(len(digits)):\n",
    "            if dic[digits[i]]==2:\n",
    "                digits+=[digits[i]]\n",
    "            elif dic[digits[i]]>=3:\n",
    "                digits+=[digits[i]]*2\n",
    "        n=len(digits)\n",
    "        for i in range(n):\n",
    "            if digits[i]!=0:\n",
    "                for k in range(n):\n",
    "                    if digits[k]%2==0:\n",
    "                        for j in range(n):\n",
    "                            if i!=j!=k!=i:\n",
    "                                res.append(digits[i]*100+digits[j]*10+digits[k])\n",
    "                            # print(res,i,j,k)\n",
    "        res=set(res)\n",
    "        return sorted(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from numpy import unique\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        n=len(digits)\n",
    "        if n<3: return []\n",
    "        dic={}     \n",
    "        res=[]   \n",
    "        for i in range(n):\n",
    "            if digits[i] not in dic:\n",
    "                dic[digits[i]]=1\n",
    "            else: dic[digits[i]]+=1\n",
    "        digits=[*dic]\n",
    "        for i in range(len(digits)):\n",
    "            if dic[digits[i]]==2:\n",
    "                digits+=[digits[i]]\n",
    "            elif dic[digits[i]]>=3:\n",
    "                digits+=[digits[i]]*2\n",
    "        print(digits)\n",
    "        n=len(digits)\n",
    "        for i in range(n):\n",
    "            if digits[i]!=0:\n",
    "                for k in range(n):\n",
    "                    if digits[k]%2==0:\n",
    "                        for j in range(n):\n",
    "                            if i!=j!=k!=i:\n",
    "                                res.append(''.join(map(str,[digits[i],digits[j],digits[k]])))\n",
    "                            # print(res,i,j,k)\n",
    "        res=set([int(i) for i in res])\n",
    "        return sorted(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        answer = []\n",
    "        length = len(digits)\n",
    "        for i in range(0,length):\n",
    "            for j in range(i+1,length):\n",
    "                for k in range(j+1,length):\n",
    "                    temp = list(set([100*digits[i]+10*digits[j]+digits[k],100*digits[i]+10*digits[k]+digits[j],100*digits[j]+10*digits[i]+digits[k],\n",
    "     100*digits[j]+10*digits[k]+digits[i],100*digits[k]+10*digits[i]+digits[j],100*digits[k]+10*digits[j]+digits[i]]))\n",
    "                    answer+=(temp)\n",
    "        answer = list(set(answer))\n",
    "        ranswer = []\n",
    "        for i in answer:\n",
    "            if i>=100 and i%2==0:\n",
    "                ranswer.append(i)\n",
    "        ranswer.sort()\n",
    "\n",
    "        return ranswer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        digits = sorted(digits)\n",
    "        n = len(digits)\n",
    "        ans = []\n",
    "        def num(i, j, k):\n",
    "            nums = sorted([i, j, k])\n",
    "            res = []\n",
    "            if nums[0]!=0:\n",
    "                res += [nums[0]*100+nums[1]*10+nums[2], nums[0]*100+nums[2]*10+nums[1]]\n",
    "            if nums[1]!=0:\n",
    "                res += [nums[1]*100+nums[0]*10+nums[2], nums[1]*100+nums[2]*10+nums[0]]\n",
    "            if nums[2]!=0:\n",
    "                res += [nums[2]*100+nums[0]*10+nums[1], nums[2]*100+nums[1]*10+nums[0]]\n",
    "            return list(set(res))\n",
    "        \n",
    "        for i in range(n-2):\n",
    "            for j in range(i+1, n-1):\n",
    "                for k in range(j+1, n):\n",
    "                    ans += num(digits[i], digits[j], digits[k])\n",
    "        \n",
    "        ans = sorted(list(set(ans)))\n",
    "        ans = [num for num in ans if num%2==0]\n",
    "        \n",
    "        return ans\n",
    "                    \n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        t=[str(i) for i in digits]\n",
    "        res=[]\n",
    "        for i in range(len(t)):\n",
    "            i1=t[:i]+t[i+1:]\n",
    "            for j in range(len(i1)):\n",
    "                j1=i1[:j]+i1[j+1:]\n",
    "                for m in range(len(j1)):\n",
    "                    if int(j1[m])%2==0:\n",
    "                        res.append(int(str(digits[i])+str(i1[j])+str(j1[m])))\n",
    "        \n",
    "        r=list(set(res))\n",
    "        r.sort()        \n",
    "        for i in range(len(r)-1,-1,-1):\n",
    "            if len(str(r[i]))<3:\n",
    "                r.pop(i)\n",
    "        return r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        res = []\n",
    "        for i in range(len(digits)):\n",
    "            temp = digits[:]\n",
    "            temp.pop(i)\n",
    "            for j in range(len(temp)):\n",
    "                temp2=temp[:]\n",
    "                temp2.pop(j)\n",
    "                for k in range(len(temp2)):\n",
    "                    if temp2[k] % 2 == 1:\n",
    "                        continue\n",
    "\n",
    "                    res.append(digits[i]*100+temp[j]*10+temp2[k])\n",
    "\n",
    "        lst= list(set(res))\n",
    "        ans = lst[:]\n",
    "        for i in lst:\n",
    "            if i < 100:\n",
    "                ans.remove(i)\n",
    "        ans.sort()\n",
    "        return ans\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        for i in range(len(digits)):\n",
    "            if digits[i] == 0:\n",
    "                continue\n",
    "            for j in range(len(digits)):\n",
    "                m = digits[i]\n",
    "                if i == j:\n",
    "                    continue\n",
    "                for k in range(len(digits)):\n",
    "                    n = m * 10 + digits[j]\n",
    "                    if k == i or k == j:\n",
    "                        continue\n",
    "                    add = n * 10 + digits[k]\n",
    "                    if add % 2 == 0:\n",
    "                        ans.append(add)\n",
    "        ans = list(set(ans))\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        l=[]\n",
    "        for i in range(len(digits)):\n",
    "            digits[i]=str(digits[i])\n",
    "        for i in range(len(digits)):\n",
    "            for j in range(i+1,len(digits)):\n",
    "                for k in range(j+1,len(digits)):\n",
    "                    if digits[i]!='0':\n",
    "                        x=int(digits[i]+digits[j]+digits[k])\n",
    "                        if x%2==0:\n",
    "                            l.append(x)\n",
    "                        x2 = int(digits[i] + digits[k] + digits[j])\n",
    "                        if x2 % 2 == 0:\n",
    "                            l.append(x2)\n",
    "                    if digits[j] != '0':\n",
    "                        x = int(digits[j] + digits[i] + digits[k])\n",
    "                        if x % 2 == 0:\n",
    "                            l.append(x)\n",
    "                        x2 = int(digits[j] + digits[k] + digits[i])\n",
    "                        if x2 % 2 == 0:\n",
    "                            l.append(x2)\n",
    "                    if digits[k]!='0':\n",
    "                        x=int(digits[k]+digits[j]+digits[i])\n",
    "                        if x%2==0:\n",
    "                            l.append(x)\n",
    "                        x2 = int(digits[k] + digits[i] + digits[j])\n",
    "                        if x2 % 2 == 0:\n",
    "                            l.append(x2)\n",
    "        x=list(set(l))\n",
    "        x.sort()\n",
    "        return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, t: List[int]) -> List[int]:\n",
    "        l=len(t)\n",
    "        r=[]\n",
    "        for i1 in range(l):\n",
    "            for i2 in range(l):\n",
    "                for i3 in range(l):\n",
    "                    if i1!=i2 and i1!=i3 and i2!=i3 and t[i1]!=0 and t[i3]%2==0:\n",
    "                        r.append(t[i1]*100+10*t[i2]+t[i3])\n",
    "        return sorted(list(set(r)))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        # 判断digits中是否全为奇数\n",
    "        evens = [d for d in digits if d % 2 == 0]\n",
    "        if len(evens) == 0:\n",
    "            return []\n",
    "        \n",
    "        # 构造偶数的条件：个位数是2的倍数\n",
    "        # 个位 = digits中的偶数\n",
    "        # 十位 = digits中的任意数除去个位\n",
    "        # 百位 = digits中的任意数除去个位、十位、0\n",
    "        # num = 百位*100 + 十位*10 + 个位\n",
    "\n",
    "        # res = sorted(set([]))\n",
    "\n",
    "        res = []\n",
    "        # 个位\n",
    "\n",
    "        \n",
    "\n",
    "        for ones in evens:\n",
    "            d1 = digits.copy()\n",
    "\n",
    "            d1.remove(ones) \n",
    "\n",
    "            for tens in d1:\n",
    "                \n",
    "                d2 = d1.copy()\n",
    "\n",
    "                d2.remove(tens)\n",
    "                \n",
    "                for h in d2:\n",
    "                    if h != 0:\n",
    "                        num = h*100 + tens*10 + ones \n",
    "                        res.append(num)\n",
    "\n",
    "        \n",
    "        return sorted(set(res))\n",
    "        \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        res =[]\n",
    "        two = [i for i in digits if i%2==0]\n",
    "        # print(two)\n",
    "        for i in two:\n",
    "            temp =digits.copy()\n",
    "            temp.remove(i)\n",
    "            for j in temp:\n",
    "                temp1 =temp.copy()\n",
    "                temp1.remove(j)\n",
    "                for k in temp1:\n",
    "                    if k!=0:\n",
    "                        res.append(int(str(k)+str(j)+str(i)))\n",
    "        a =sorted(list(set(res)))\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        s = []\n",
    "        for i in range(0, len(digits)):\n",
    "            for j in range(0, len(digits)):\n",
    "                for k in range(0, len(digits)):\n",
    "                    num = 100*digits[i]+10*digits[j]+digits[k]\n",
    "                    if num % 2 == 0 and digits[i] != 0 and i != j and j != k and i != k:\n",
    "                        s.append(num)\n",
    "                    else:\n",
    "                        continue\n",
    "        s2 = list(set(s))\n",
    "        s2.sort()\n",
    "        return s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        ans = []\n",
    "        n = len(digits)\n",
    "        for n1 in range(n):\n",
    "            for n2 in range(n):\n",
    "                for n3 in range(n):\n",
    "                    if n1 == n2 or n2 == n3 or n1 == n3:\n",
    "                        continue\n",
    "                    p = digits[n1] * 100 + digits[n2] * 10 + digits[n3]\n",
    "                    if (p) % 2 == 0 and p >= 100:\n",
    "                        ans.append(p)\n",
    "\n",
    "        ans = list(set(ans))\n",
    "        ans.sort()\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def findEvenNumbers(self, digits: List[int]) -> List[int]:\n",
    "        digits.sort()\n",
    "        returnnum = []\n",
    "        n = len(digits)\n",
    "        for i in range (n):\n",
    "            if digits[i] == 0:\n",
    "                continue\n",
    "            for j in range(n):\n",
    "                for k in range (n):\n",
    "                    if digits[k] % 2 != 0:\n",
    "                        continue\n",
    "                    if i != j and i != k and j != k:\n",
    "                        returnnum.append(digits[i] * 100 + digits[j] * 10 + digits[k])\n",
    "        returnnum = set(returnnum)\n",
    "        returnnum = list(returnnum)\n",
    "        returnnum.sort()\n",
    "        return returnnum\n",
    "                    \n"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
